package me.ratel.demo.wechat;

import com.alibaba.fastjson.JSONObject;
import me.ratel.demo.wechat.entities.BrandWCPayRequest;
import me.ratel.demo.wechat.entities.GetMenuResponse;
import me.ratel.demo.wechat.entities.OAuth2UserInfo;
import me.ratel.demo.wechat.entities.OrderQueryResponse;
import me.ratel.demo.wechat.entities.SnsOAuth2AccessTokenResponse;
import me.ratel.demo.wechat.entities.UnifiedOrderResponse;

/**
 * @author Administrator
 * @time 2016/8/28 13:20
 */
public interface WeChatService {
    /**
     * 查询菜单接口
     *
     * @return GetMenuResponse
     */
    GetMenuResponse getMenu();

    /**
     *  统一下单
     *
     * @see <a href="https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1">统一下单</a>
     *
     *@param body 商品描述
     *@param detail
     * @param outTradeNo
     * @param openId
     * @param spbillCreateIP
     * @param totalFee
     * @param tradeType
     * @return UnifiedOrderResponse
     */
    UnifiedOrderResponse unifiedOrder(String body, JSONObject detail, String notifyURL, String outTradeNo, String openId, String spbillCreateIP, int totalFee, String tradeType);

    /**
     *
     * 网页端调起支付API参数
     *
     * @param prepayId
     * @return BrandWCPayRequest
     */
    BrandWCPayRequest getBrandWCPayRequest(String prepayId);

    /**
     * 查询订单
     *
     * @param outTradeNo
     * @return OrderQueryResponse
     */
    OrderQueryResponse orderQuery(String outTradeNo);

    /**
     * 生成授网页权URL
     *
     * @param redirectUri
     * @return String
     */
    String createOauth2AuthorizeURL(String redirectUri);

    /**
     * 通过code换取网页授权access_token
     * @param code
     * @return SnsOAuth2AccessTokenResponse
     */
    SnsOAuth2AccessTokenResponse snsOAuth2AccessToken(String code);

    /**
     * 刷新access_token
     *
     * @param refreshToken
     * @return SnsOAuth2AccessTokenResponse
     */
    SnsOAuth2AccessTokenResponse refreshOAuth2AccessToken(String refreshToken);

    /**
     * 拉取用户信息
     *
     * @param accessToken
     * @param openId
     * @return OAuth2UserInfo
     */
    OAuth2UserInfo snsUserInfo(String accessToken, String openId);
}
